package com.derbysoft.lowcostadapter.commons.model;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "dswitch3_transaction_log")
public class TransactionLog extends Base {

    @Enumerated(EnumType.STRING)
    @Column(length = 30, nullable = false)
    private OperationType operationType;

    @Column(length = 100)
    private String taskId;

    @Column(length = 100)
    private String channel;

    @Column(columnDefinition = "longtext")
    private String hotels;

    @Column(columnDefinition = "longtext")
    private String exception;

    private boolean error;

    private Date timestamp = new Date();

    private Long timeSpan;

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "transactionLog")
    private List<TransactionDetail> transactionDetails;

    public List<TransactionDetail> getTransactionDetails() {
        return transactionDetails;
    }

    public void setTransactionDetails(List<TransactionDetail> transactionDetails) {
        this.transactionDetails = transactionDetails;
    }


    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getHotels() {
        return hotels;
    }

    public void setHotels(String hotels) {
        this.hotels = hotels;
    }

    public OperationType getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationType operationType) {
        this.operationType = operationType;
    }


    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public boolean isError() {
        return error;
    }

    public void setError(boolean error) {
        this.error = error;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Long getTimeSpan() {
        return timeSpan == null ? 0L : timeSpan;
    }

    public void setTimeSpan(Long timeSpan) {
        this.timeSpan = timeSpan;
    }
}
